package chartUtils;

import java.util.ArrayList;

public class PointList {

    private ArrayList<Point> points;

    public ArrayList<Point> getPoints() {
        return points;
    }

    public void setPoints(ArrayList<Point> points) {
        this.points = points;
    }

    public PointList() {
        this.points = new ArrayList<>();
    }

    public Double getXmin() {
        Double xmin = Double.POSITIVE_INFINITY;
        Double x = Double.NaN;
        for (Point point : points) {
            x = point.getX();
            if (x < xmin) {
                xmin = x;
            }
        }
        return xmin;
    }

    public Double getXmax() {
        Double xmax = Double.NEGATIVE_INFINITY;
        Double x = Double.NaN;
        for (Point point : points) {
            x = point.getX();
            if (x > xmax) {
                xmax = x;
            }
        }
        return xmax;
    }

    public Double getYmin() {
        Double ymin = Double.POSITIVE_INFINITY;
        Double y = Double.NaN;
        for (Point point : points) {
            y = point.getY();
            if (y < ymin) {
                ymin = y;
            }
        }
        return ymin;
    }

    public Double getYmax() {
        Double ymax = Double.NEGATIVE_INFINITY;
        Double y = Double.NaN;
        for (Point point : points) {
            y = point.getY();
            if (y > ymax) {
                ymax = y;
            }
        }
        return ymax;
    }

}
